import java.io.*; 
import java.util.*;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;


public class SubmitAs {

public static String userName = null;
public static String[] result=new String [500];
public static String DayNow = null;


public static void input_handle() {
    
      System.out.print("Please Enter your Student Id, Subject Name ,Assignment Name and File path seperated by commas : "); 

      
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));  

      
      try { 
         userName = br.readLine(); 
      } catch (IOException ioe) { 
         System.out.println("Error while submitting your assignment, please try again!"); 
         input_handle();
      }


 	int idx=0; int tokenCount;
    


	 result = userName.split(",");



      System.out.println(result[0]+", Thank you for submitting your assignment"); 


}






  public static void main(String[] args) throws IOException {

	//get date used for future developments
	DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
        Date date = new Date();
        DayNow = dateFormat.format(date);
	//

    

	input_handle();


    int index1 = result[3].lastIndexOf("."); 
    int index2 = result[3].length();  
    String index3 = result[3].substring(index1,index2); 


    File inputFile = new File(result[3]);
    File outputFile = new File("c:\\Agile\\Assignments\\"+result[0]+" "+result[1]+" "+result[2]+""+index3);

    FileReader in = new FileReader(inputFile);
    FileWriter out = new FileWriter(outputFile);
    int c;

    while ((c = in.read()) != -1)
    out.write(c);

    in.close();
    out.close();

	
    
  }



}
